/**
 * 项目名称: Topic_617.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月12日07时58分45秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    void add(TreeNode *root1,TreeNode*root2){
        if(!root1->left && root2->left){
            TreeNode * p =new TreeNode;
            p->val = root2->left->val;
            root1->left = p;
        }
        if(!root1->right&&root2->right){
            TreeNode * p =new TreeNode;
            p->val = root2->right->val;
            root1->right = p;
        }
    }
    void Order(TreeNode * root1,TreeNode * root2,bool flag){
        if(root1&&root2){
            cout<<root1->val<<endl;

            if(!flag)root1->val +=root2->val;
            if(flag)add(root1,root2);

            Order(root1->left, root2->left,flag);
            Order(root1->right, root2->right,flag);
        }
    }
    TreeNode* mergeTrees(TreeNode* root1, TreeNode* root2) {
        if(!root1)return root2;
        Order(root1,root2, false);
        Order(root1,root2, true);
        return root1;
    }
};

int main() {

    return 0;
}
